script_enemy_main{

let distance=0;
let angle1=0;
let angle2=0;
let baseangle=0;
let phase=rand_int(0,1);

let character="Youko";
let cutin=character;
let spellcards=1;
let dispelled=0;
let damagerate=10;
let outfit=1;
outfit=(128*outfit)-128;
let usespell=0;
let bgfade=0;
let frame=0; let time=0;
let miny=GetClipMinY; let maxy=GetClipMaxY; let minx=GetClipMinX; let maxx=GetClipMaxX;
let cx=GetCenterX; let cy=GetCenterY;

let SEshotb5=("\script\SoundEffects\shotb5.wav");
let SElasers1=("\script\SoundEffects\lasers1.wav");

let GRboss=("\script\Images\CharacterSprites\Youko.png");

#include_function "script/Functions/SpellcardNameLoad.txt";
#include_function "script/Functions/HealthBarLoad.txt";
#include_function "script/Functions/CutInLoad.txt";

@Initialize{
	LoadUserShotData("script\shots\ShotsYouko1.txt");

	LoadGraphic("\script\Images\CharacterSprites\Youko.png");

	LoadSE("\script\SoundEffects\shotb5.wav");
	LoadSE("\script\SoundEffects\shotm3.wav");
	LoadSE("\script\SoundEffects\lasers1.wav");

	SetLife(125);
	SetTimer(30);
	SetInvincibility(120);
	SetDamageRate(10,10); 
	SetEnemyMarker(true);
	MagicCircle(true);

	SetX(GetCommonData("Boss1X"));
	SetY(GetCommonData("Boss1Y"));
	SetCommonData("Boss1Vanish",1);

	SetMovePosition02(cx,miny+100,50);
}
	
@MainLoop{

SetCollisionA(GetX,GetY,16);
SetCollisionB(GetX,GetY,16);
SetShotAutoDeleteClip(64,64,64,64);

Weakness(character);
#include_function "script/Functions/Weakness.txt";
if(GetCommonData("BombOn")==0){ damagerate=10; }
if(GetCommonData("BombOn")==1){ damagerate=4; }
SetDamageRate(damagerate*weaken,damagerate*weaken);

HealthBar();

if(GetCommonData("Difficulty")==1){

if(frame==60){ baseangle=rand(0,360); }
if(frame>=60 && frame%2==0){
let shot1=0;
	if(phase%2==0){
	CreateLaserA(shot1,cx,cy,600,10,15,40);
	SetLaserDataA(shot1,0,baseangle+angle1,0,0,0,0);
	SetShotKillTime(shot1,120);
	FireShot(shot1);
	}
	if(phase%2!=0){
	CreateLaserA(shot1,cx,cy,600,10,15,40);
	SetLaserDataA(shot1,0,baseangle-angle2,0,0,0,0);
	SetShotKillTime(shot1,120);
	FireShot(shot1);
	}
angle1+=17;
angle2+=17;
usespell=5;
PlaySE(SElasers1);
}

if(angle1>360 || angle2>360){ frame=-60; angle1=0; angle2=0; phase+=1; }

if(time%60==0 && time>=60){
let angle=GetAngleToPlayer;
	loop(15){
	CreateShot01(GetX,GetY,1.5,angle+rand(-2,2),1,0);
	angle+=360/15;
	}
PlaySE(SEshotb5);
}

} //Easy

//=============================================================================================================

if(GetCommonData("Difficulty")==2){

if(frame==60){ baseangle=rand(0,360); }
if(frame>=60 && frame%2==0){
let shot1=0;
	if(phase%2==0){
	CreateLaserA(shot1,cx,cy,600,10,15,40);
	SetLaserDataA(shot1,0,baseangle+angle1,0.05,0,0,0);
	SetShotKillTime(shot1,120);
	FireShot(shot1);
	}
	if(phase%2!=0){
	CreateLaserA(shot1,cx,cy,600,10,15,40);
	SetLaserDataA(shot1,0,baseangle-angle2,-0.05,0,0,0);
	SetShotKillTime(shot1,120);
	FireShot(shot1);
	}
angle1+=13;
angle2+=13;
usespell=5;
PlaySE(SElasers1);
}

if(angle1>360 || angle2>360){ frame=-60; angle1=0; angle2=0; phase+=1; }

if(time%60==0 && time>=60){
let angle=GetAngleToPlayer;
	loop(20){
	let speed=1.5;
		loop(2){
		CreateShot01(GetX,GetY,speed,angle+rand(-2,2),1,0);
		speed-=0.3;
		}
	angle+=360/20;
	}
PlaySE(SEshotb5);
}

} //Normal

//=============================================================================================================

if(GetCommonData("Difficulty")==3){

if(frame==60){ baseangle=rand(0,360); }
if(frame>=60 && frame%2==0){
let shot1=0;
	if(phase%2==0){
	CreateLaserA(shot1,cx,cy,600,10,15,40);
	SetLaserDataA(shot1,0,baseangle+angle1,0.1,0,0,0);
	SetShotKillTime(shot1,120);
	FireShot(shot1);
	}
	if(phase%2!=0){
	CreateLaserA(shot1,cx,cy,600,10,15,40);
	SetLaserDataA(shot1,0,baseangle-angle2,-0.1,0,0,0);
	SetShotKillTime(shot1,120);
	FireShot(shot1);
	}
angle1+=10;
angle2+=10;
usespell=5;
PlaySE(SElasers1);
}

if(angle1>360 || angle2>360){ frame=-30; angle1=0; angle2=0; phase+=1; }

if(time%60==0 && time>=60){
let angle=GetAngleToPlayer;
	loop(25){
	let speed=2;
		loop(2){
		CreateShot01(GetX,GetY,speed,angle+rand(-4,4),1,0);
		speed-=0.3;
		}
	angle+=360/25;
	}
PlaySE(SEshotb5);
}

} //Hard

//=============================================================================================================

if(GetCommonData("Difficulty")==4){

if(frame==60){ baseangle=rand(0,360); }
if(frame>=60 && frame%2==0){
let shot1=0;
	if(phase%2==0){
	CreateLaserA(shot1,cx,cy,600,10,15,40);
	SetLaserDataA(shot1,0,baseangle+angle1,0.15,0,0,0);
	SetShotKillTime(shot1,120);
	FireShot(shot1);
	}
	if(phase%2!=0){
	CreateLaserA(shot1,cx,cy,600,10,15,40);
	SetLaserDataA(shot1,0,baseangle-angle2,-0.15,0,0,0);
	SetShotKillTime(shot1,120);
	FireShot(shot1);
	}
angle1+=8;
angle2+=8;
usespell=5;
PlaySE(SElasers1);
}

if(angle1>360 || angle2>360){ frame=-30; angle1=0; angle2=0; phase+=1; }

if(time%60==0 && time>=60){
let angle=GetAngleToPlayer;
	loop(25){
	let speed=2;
		loop(3){
		CreateShot01(GetX,GetY,speed,angle+rand(-4,4),1,0);
		speed-=0.3;
		}
	angle+=360/25;
	}
PlaySE(SEshotb5);
}

} //Lunatic


time++; frame++;
if(usespell>0){ usespell--; } if(usespell<0){ usespell++; }
SetCommonData("Boss1X",GetX); SetCommonData("Boss1Y",GetY);

#include_function "script/Functions/HealthBar.txt";
}

@DrawLoop{
	SetGraphicScale(1,1);
	SetTexture(GRboss);
	SetGraphicAngle(0,0,0);
	SetColor(255,255,255);
	SetRenderState(ALPHA);

	if(usespell>=1){ SetGraphicRect(384,outfit,512,outfit+128); }
	if(usespell<=-1){ SetGraphicRect(512,outfit,640,outfit+128); }

	if(usespell==0){
		if(GetSpeedX<=0.5 && GetSpeedX>=-0.5){ SetGraphicRect(0,outfit,128,outfit+128); }
		else if(GetSpeedX<-0.5){ SetGraphicRect(128,outfit,256,outfit+128); }
		else if(GetSpeedX>0.5){ SetGraphicRect(256,outfit,384,outfit+128); }
	}
	if(GetLife>0){ DrawGraphic(GetX,GetY); }
}
 
@Finalize{
//	SetCommonData("Conversation",1);
}

}